package com.freesun.shop.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * 用户的的权限
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Auth implements Serializable {

    public static final String USER_AUTH_PREFIX="user:auth:";
    private static final long serialVersionUID = 3096499165111901201L;
    @ApiModelProperty("权限的值")
    private String authority;

    public static Auth of(String authority){

        if(!StringUtils.hasText(authority)){
            throw new RuntimeException("权限信息不能为NULL");
        }
        return new Auth(authority);
    }
}
